{% extends '::base.html.twig' %}

{% block resources_attributes %} class="active"{% endblock %}

{% block title %}{% trans %}Educino Blogs{% endtrans %}{% endblock %}

{% block body %}

<div class="row-fluid whiteWrapper blogPage">

    <form class="form-horizontal formHead" action="{{ path('list_blogs') }}">
        <fieldset>
            <legend>{% trans %}Blog{% endtrans %}</legend>
            <hr class="smallHr">
            <div class="control-group right searchTop">
                <label class="control-label" >&nbsp;</label>
                <div class="controls">

                    <div class="input-append">
                        <input class="input-large" placeholder="" type="text" name="title"/>
                        <button class="btn blue" type="submit">{% trans %}Search Blog{% endtrans %}</button>
                    </div>
                </div>
            </div>
        </fieldset>
    </form>

    {% for post in posts %}
    <div class="postBlock">
        <a href="{{ path('show_blog',{'id' : post.id}) }}"><h5>&raquo; {{ post.getTitle(locale) }}</h5></a>
        <p>
            {{ post.getSmallDesc(locale) }}
            <a class="readmore" href="{{ path('show_blog',{'id' : post.id}) }}">read more</a>
        </p>
    </div>
    {% else %}
    <div class="postBlock">
        <p>
            {% trans %}No Blogs Found.{% endtrans%}
        </p>
    </div>
    {% endfor %}

    {% if lastPageNumber > 1 %}
    <div class="pagination right">
        {% set paginationParameters = app.request.attributes.get('_route_params') | merge(app.request.query.all()) %}
        <ul>
            {% if page > 1 %}
            <li><a href="{{ path(app.request.attributes.get('_route'), paginationParameters | merge({'page': page-1 })) }}">&laquo;</a></li>
            {% endif %}
        {% for numberOfPage in 1..lastPageNumber %}
            {% if numberOfPage > page - 3 and numberOfPage < page + 3 %}
            <li class="{% if page == numberOfPage %}disabled{% endif %}"><a href="{{ path(app.request.attributes.get('_route'), paginationParameters | merge({'page': numberOfPage})) }}">{{ numberOfPage }}</a></li>
            {% endif %}
        {% endfor %}
        {% if page < lastPageNumber %}
            <li><a href="{{ path(app.request.attributes.get('_route'), paginationParameters | merge({'page': page+1})) }}">&raquo;</a></li>
        {% endif %}
        </ul>
    </div>
    {% endif %}


</div>
{% endblock %}